Total Complexity | 2 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { |
||
18 | |||
19 | @Controller('events') |
||
20 | @ApiUseTags('Event') |
||
21 | @ApiBearerAuth() |
||
22 | @UseGuards(AuthGuard('bearer')) |
||
23 | export class UpdateEventAction { |
||
24 | constructor( |
||
25 | @Inject('ICommandBus') |
||
26 | private readonly commandBus: ICommandBus |
||
27 | ) {} |
||
28 | |||
29 | @Put(':id') |
||
30 | @ApiOperation({title: 'Update event'}) |
||
31 | public async index( |
||
32 | @Param() idDto: EventIdDTO, |
||
33 | @Body() dto: EventDTO, |
||
34 | @LoggedUser() user: User |
||
35 | ) { |
||
36 | const {type, time, summary, projectId, taskId} = dto; |
||
37 | |||
38 | try { |
||
39 | const id = await this.commandBus.execute( |
||
40 | new UpdateEventCommand( |
||
41 | idDto.id, |
||
42 | user, |
||
43 | type, |
||
44 | Number(time), |
||
45 | projectId, |
||
46 | taskId, |
||
47 | summary |
||
48 | ) |
||
49 | ); |
||
50 | |||
51 | return {id}; |
||
52 | } catch (e) { |
||
53 | throw new BadRequestException(e.message); |
||
54 | } |
||
57 |